package com.shanzmoo.merchant.server.api.web.integral;

import com.shanzmoo.base.bean.SHttpResponse;
import com.shanzmoo.base.constant.e.LoginUserType;
import com.shanzmoo.db.module.integral.domain.dto.IntegralOrderInfoDto;
import com.shanzmoo.db.module.integral.domain.dto.IntegralOrderSaveDto;
import com.shanzmoo.db.module.integral.domain.vo.IntegralOrderVo;
import com.shanzmoo.merchant.server.api.aspect.UserAuth;
import com.shanzmoo.merchant.server.api.manager.integral.IntegralOrderManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 权益订单
 * @author fs
 */
@Slf4j
@Api(tags = "权益订单")
@RestController
@RequestMapping("/integral-order")
@RequiredArgsConstructor
public class IntegralOrderController {
    private final IntegralOrderManager integralOrderManager;
    @ApiOperation(value = "创建订单")
    @PostMapping("/create-order")
    @UserAuth({LoginUserType.PT_FORMAL})
    public SHttpResponse<IntegralOrderVo> createOrder(@RequestBody IntegralOrderSaveDto param) {
        return SHttpResponse.ok(integralOrderManager.createOrder(param));
    }

    @ApiOperation(value = "提交订单")
    @PostMapping("/save-order")
    @UserAuth({LoginUserType.PT_FORMAL})
    public SHttpResponse<IntegralOrderVo> saveOrder(@RequestBody IntegralOrderSaveDto param) {
        return SHttpResponse.ok(integralOrderManager.saveOrder(param));
    }

    @ApiOperation(value = "支付订单")
    @PostMapping("/pay-order")
    @UserAuth({LoginUserType.PT_FORMAL})
    public SHttpResponse<IntegralOrderVo> payOrder(@RequestBody IntegralOrderInfoDto param) {
        return SHttpResponse.ok(integralOrderManager.payOrder(param));
    }

    @ApiOperation(value = "订单详情")
    @PostMapping("/order-info")
    @UserAuth({LoginUserType.PT_FORMAL})
    public SHttpResponse<IntegralOrderVo> orderInfo(@RequestBody IntegralOrderInfoDto param) {
        return SHttpResponse.ok(integralOrderManager.orderInfo(param));
    }
}
